import Request from "@/utils/Request";

const Api = {
    //用户操作
    login: "/auth/login",//登录
    logout:"/auth/logout",//退出登录
    refreshJwt: "/auth/refreshJwt",//刷新jwt
    register: "/auth/register",//注册
    askCode: "/auth/ask-code",//获取验证码
    Captcha: "/img/captcha",//获取验证码
    userInfo: "/auth/userInfo",//获取用户信息
    code: "/auth/code",//获取验证码
    //视频操作
    loadRecommendVideo:"/video/loadRecommendVideo",//加载推荐视频
    loadVideo: "/video/loadVideo",//加载视频
    getVideoInfo: "/video/getVideoInfo",//获取视频信息
    loadVideoPList: "/video/loadVideoPList",//加载视频播放列表
    //弹幕操作
    LoadDanmu: "/video/LoadDanmu",//加载弹幕
    addDanmu: "/video/addDanmu",//添加弹幕
    //观看人数操作
    addWatch: "/video/addWatch",//添加观看人数
    loadWatch: "/video/loadWatch",//加载观看人数
    //评论操作
    loadVideoComment: "/comment/loadComment",//加载视频评论
    addComment: "/comment/addComment",//添加评论
    deleteComment: "/comment/deleteComment",//删除评论
    topComment: "/comment/topComment",//置顶评论
    cancelTopComment: "/comment/cancelTopComment",//取消置顶评论
    upload_comment: "/file/upload_comment",//上传评论图片
    //首页
    loadAll: "/category/loadAllCategory",//获取所有分类"
    //上传图片
    uploadImage: "/file/upload_tx",//头像图片上传
    userAction: "/v1/user_action",
    sourcePath: "file/imgUrl"//获取头像路径
}

//上传封面
const uploadImage = async (file, createThumbnail = false) => {
    let result = await Request({
        url: Api.uploadImage,
        params: {
            file,
            createThumbnail
        },
    })
    if (!result) {
        return;
    }
    return result.data;
}

const doUserAction = async (config, callback) => {
    let result = await Request({
        url: Api.userAction,
        params: config,
        showLoading: true,
    })
    if (!result) {
        return;
    }
    callback()
}

export {
    Api,
    uploadImage,
    doUserAction
}